<?php
require_once ('config.php');
require_once ('databasefunctions.php');
require_once ('displayfunctions.php');
require_once ('businessfunctions.php');

$datepattern = $_POST["Year"]."-".$_POST["Month"]."-%";
$companyid = $_POST["CompanyID"];
$staffid = $_POST["StaffID"];
$withheading = $_POST["WithHeading"];

$sql  = "SELECT * FROM billtransaction ";
$sql .= "WHERE transactiondate LIKE '$datepattern' ";
$sql .= "AND companyid = '$companyid' ";
$sql .= "AND staffid = '$staffid' ";
if ($withheading!="%")
	$sql .= "AND withheading = $withheading ";
$sql .= "ORDER BY transactiondate ASC";
$exprep = sql_execute($sql);

//die($sql);

$StaffData  = mysql_fetch_array(sql_execute("select * from staffmaster where StaffID='$staffid'"));

// Company Data
$sql = "SELECT * FROM companymaster WHERE CompanyID = '$companyid'" ;
$sql_result = sql_execute($sql);
$company_data = mysql_fetch_array($sql_result);
$companyname = $company_data['CompanyName'];

?>



<html>
<head>
<title>Custom Bill Print</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</head>
<LINK REL="StyleSheet" HREF="styleprint.css" TYPE="text/css">
<body>

  <div align="center">
       <img src="img/logo.png" alt="GDA Logo" border=0><br>
       <b><?echo $company_data['CompanyName']?></b>&nbsp;&nbsp;
       <?echo $company_data['additional']?>
       <hr>
  </div>
  <div align="right">
  <a class="none" href="javascript:history.back();"><img src="img/back.gif" border="0"></a>&nbsp;&nbsp;
  <a class="none" href="javascript:window.print();"><img src="img/printer.gif" border="0"></a>
  </div>
  <br><br>
  <img src="" width="" height="" alt="" border="0">

  <h1><? echo $langexpensereport?></h1>

  <table border=1 cellpadding=2>
  <tr>	<td><? echo $langstaffname ?>
  		<td><b><? echo $StaffData["StaffName"]?></b>
  <tr>	<td><? echo $langmonth?>
  		<td><b><? echo ($_POST["Month"]."-".$_POST["Year"])?></b>
  </table>

  <br><br>

  <table border=1 cellpadding=2>
  <tr>
  <th><? echo $langtransactiondate?>
  <th><? echo $langexpense?>
  <th><? echo $langunitprice." (".$company_data["Currency"].")"?>
  <th><? echo $langqtyhour?>
  <th><? echo $langamount." (".$company_data["Currency"].")"?>
  <th><? echo $langremark?>

  <?
  while ($sql_data = mysql_fetch_array($exprep)) {
  	$totalexp += $sql_data["ChargeRate"] * $sql_data["Quantity"];
  ?>
	<tr border=1>
	<td><? echo convert_mysql_date4output($sql_data["TransactionDate"])?>
    <td><? echo get_charge_desc($sql_data["ChargeID"])?>
    <td align=right><? printf('%.2f',$sql_data["ChargeRate"])?>
    <td align=right><? echo $sql_data["Quantity"]?>
    <td align=right><? printf('%.2f',$sql_data["ChargeRate"] * $sql_data["Quantity"])?>
    <td><? echo $sql_data["Remark"]?>
  <?
  }
?>
	<tr><td colspan=4><? echo $langtotal." (".$company_data["Currency"].")" ?>
	<td align=right><? printf('%.2f',$totalexp)?>
</body>

